#include "constants.h"
#include "http_controller.h"
#include <sstream>
#include <string>

const std::string HttpController::FindMethodName4QStr(const HttpRequest& request)
{
	std::string ret("");
	auto iter = request.requestParams.find(KEY_METHOD_NAME);
	if (iter != request.requestParams.end())
	{
		ret = iter->second;
	}
	return ret;
}

std::vector<std::string> HttpController::FindMethodArgs4QStr(const HttpRequest& request)
{
	std::vector<std::string> args;
	auto iter = request.requestParams.find(KEY_METHOD_ARGS);
	if (iter != request.requestParams.end())
	{
		if (iter->second != "")
		{
			std::istringstream iss(iter->second);
			std::string token;
			
			while (std::getline(iss, token, KEY_METHOD_ARGS_SEP))
			{
				args.push_back(token);
			}
		}
		
	}
	return args;
}

